package LeetCode;

public class LC_477_TotalHammingDistance {

    public static void main(String[] args) {

    }

    public class Solution {
        public int totalHammingDistance(int[] nums) {
            int total = 0;
            int n = nums.length;
            for (int i = 0; i < 32; i++) {
                int counter = 0;
                for (int num : nums)
                    counter += (num >> i) & 0x01;
                total += counter * (n - counter);
            }
            return total;
        }

    }
}